﻿using System;
using fastCSharp;

namespace diantou.web.emanagement
{
    /// <summary>
    /// 问题集合
    /// </summary>
    abstract class questionList<viewType> : permissionView<viewType>
        where viewType : questionList<viewType>
    {
        /// <summary>
        /// 问题集合
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        protected exam.userQuestion[] questions;
        /// <summary>
        /// 考试类型
        /// </summary>
        protected abstract dataModel.examQuestion.type type { get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        protected bool loadView(int page, diantou.dataAccess.problem.showType showType, diantou.examDataAccess.examQuestion.publicType publicType, int userId)
        {
            if ((currentUser.Permission & dataModel.user.permission.ExamEditor) != 0)
            {
                diantou.examDataAccess.examQuestion[] values = diantou.examDataAccess.tcpCall.examQuestion.get(type, showType, publicType, userId, pageInfo.Size = 20, pageInfo.Page = page, currentUserId, out pageInfo.Count);
                if (currentUser.Permission != dataModel.user.permission.Admin)
                {
                    foreach (diantou.examDataAccess.examQuestion value in values) value.UsedCount = 0;
                }
                questions = values.getArray(value => new exam.userQuestion { Question = value, User = currentUser });
                return true;
            }
            AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = currentUser.Path.NewFocus });
            return false;
        }
    }
}
